package com.white.algebra.utils;

public class StringUtils {
    //
    public static double[][] stringToDoubleArray(String string){
        String[] divideRows=string.split("\r\n");
        int row=divideRows.length;
        String[] temp=divideRows[0].split(" ");
        int col=temp.length;
        double[][] end=new double[row][col];
        for(int i=0;i<row;i++) {
            for(int j=0;j<col;j++) {
                end[i][j]=Double.parseDouble(divideRows[i].split(" ")[j]);
            }
        }
        return end;
    }
    public static String doubleToStringArray(double[][] doubles){
        String end="";
        int row=doubles.length;
        int col=doubles[0].length;
        for(int i=0;i<row;i++) {
            for(int j=0;j<col;j++) {
                end=end+doubles[i][j]+" ";
            }
            end=end+"\r\n";
        }
        return end;
    }
}
